package com.killer.redissessiondemo.controller;

import com.killer.redissessiondemo.pojo.Resume;
import com.killer.redissessiondemo.service.ResumeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @author ：Killer
 * @date ：Created in 20-11-16 上午10:56
 * @description：${description}
 * @modified By：
 * @version: version
 */
@Controller
@RequestMapping("resume")
public class ResumeController {

    @Autowired
    private ResumeService resumeService;

    @RequestMapping("/list")
    @ResponseBody
    public List<Resume> listResume(){
        return resumeService.list();
    }

    @RequestMapping("addResume")
    public void addResume(HttpServletResponse response,Resume resume) throws IOException {
        resumeService.addResume(resume);
        response.sendRedirect("/index.html");
    }

    @RequestMapping("deleteResume")
    public void deleteResume(@RequestParam("id") Long id,HttpServletResponse response) throws IOException {
        resumeService.deleteResume(id);
        response.sendRedirect("/index.html");
    }
}
